// pages/my-order/my-order.js
var app = getApp()
Page({

    /**
     * Page initial data
     */
    data: {
		orderTime:"-",
		money:"-",
    },

    /**
     * Lifecycle function--Called when page load
     */
    onLoad(options) {
        if (!app.getopenid()) {
            wx.showToast({
                title: '登录已过期，请重新登录',
                duration: 1000,
                icon: 'none'
              })
            setTimeout(function() {
                wx.reLaunch({
                    url: '../index/index'
                })
              }, 1000)
        } else {
			this.getMyOrder()
		}
    },

	async getMyOrder() {
		var that = this
        var url= app.globalData.BASE_URL + '/mallUserGetMyOrder'
        var data = {
            userId: app.getopenid()
        }
        console.log(data.userId)
		let ret = await app.reqServer(url, data, 'GET')
		console.log(ret)
        if (ret) {
			this.setData({
				orderTime: ret.orderTime,
				money: ret.money + "元"
			})
        }
    },
    /**
     * Lifecycle function--Called when page is initially rendered
     */
    onReady() {

    },

    /**
     * Lifecycle function--Called when page show
     */
    onShow() {

    },

    /**
     * Lifecycle function--Called when page hide
     */
    onHide() {

    },

    /**
     * Lifecycle function--Called when page unload
     */
    onUnload() {

    },

    /**
     * Page event handler function--Called when user drop down
     */
    onPullDownRefresh() {

    },

    /**
     * Called when page reach bottom
     */
    onReachBottom() {

    },

    /**
     * Called when user click on the top right corner to share
     */
    onShareAppMessage() {

    },
})